home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / ike.zip / ICONPROC.C < prev    next >
C/C++ Source or Header  |  1991-01-08  |  22KB  |  657 lines

  1. /*===========================================================================*/
  2. /*                                                                           */
  3. /* File    :  ICONPROC.C                                                     */
  4. /*                                                                           */
  5. /* Purpose :  Contains the winproc's for the various window classes.         */
  6. /*                                                                           */
  7. /* History :                                                                 */
  8. /*                                                                           */
  9. /* (C) Copyright 1991      Marc Adler/Magma Systems     All Rights Reserved  */
  10. /*===========================================================================*/
  11.  
  12. #include <memory.h>
  13. #include <windows.h>
  14. #include "ico.h"
  15.  
  16. typedef struct tagScrapInfo
  17. {
  18.   HANDLE hPasteBuffer;
  19.   int    iWidth, iHeight;
  20. } SCRAPINFO;
  21.  
  22. SCRAPINFO ScrapInfo =
  23. {
  24.   NULL, 0, 0
  25. };
  26.  
  27.  
  28. WORD CurrentColor = 0;
  29. WORD iCurrentTool = ID_PENCIL;
  30. RECT rMarked;
  31.  
  32.  
  33. /****************************************************************************/
  34. /*                                                                          */
  35. /* Function : ICOViewWndProc                                                */
  36. /*                                                                          */
  37. /* Purpose  : Winproc for the main window                                   */
  38. /*                                                                          */
  39. /* Returns  :                                                               */
  40. /*                                                                          */
  41. /****************************************************************************/
  42. long FAR PASCAL ICOViewWndProc(hWnd, message, wParam, lParam)
  43.   HWND hWnd;
  44.   unsigned message;
  45.   WORD wParam;
  46.   LONG lParam;
  47. {
  48.   FARPROC lpProc;
  49.   char    buf[128];
  50.   int     rc, i;
  51.  
  52.   switch (message)
  53.   {
  54.     case WM_COMMAND :
  55.       switch(wParam)
  56.       {
  57.         case IDM_NEW:
  58.           if (IconPromptForSave(hWnd) == FALSE)
  59.             break;
  60.           NewIcon();
  61.           InvalidateAllWindows();
  62.           break;
  63.  
  64.         case IDM_OPEN:
  65.           if (IconPromptForSave(hWnd) != IDCANCEL)
  66.           {
  67.             lpProc = MakeProcInstance(OpenFileDlgProc, hInst);
  68.             rc = DialogBox(hInst, (LPSTR) "OPEN", hWnd, lpProc);
  69.             FreeProcInstance(lpProc);
  70.           }
  71.           break;
  72.  
  73.         case IDM_SAVE:
  74.           if (IconInfo.szFilename[0])
  75.           {
  76.             ICOWrite(IconInfo.szFilename, IconInfo.hBitmapBits);
  77.             break;
  78.           }
  79.           /* fall through...*/
  80.  
  81.         case IDM_SAVEAS:
  82.           lpProc = MakeProcInstance(SaveAsDlgProc,hInst);
  83.           rc = DialogBox(hInst, (LPSTR) "SAVE", hWnd, lpProc);
  84.           FreeProcInstance(lpProc);
  85.           break;
  86.  
  87.         case IDM_EXIT:
  88.           if (IconPromptForSave(hWnd) == TRUE)
  89.             PostQuitMessage(0);
  90.           break;
  91.  
  92.         case IDM_ABOUT:
  93.           /*
  94.             Display the "About" box
  95.           */
  96.           lpProc = MakeProcInstance(About, hInst);
  97.           DialogBox(hInst, "About", hWnd, lpProc);
  98.           FreeProcInstance(lpProc);
  99.           break;
  100.  
  101.         case IDM_COPY :
  102.           if (IconInfo.fFlags & STATE_SOMETHING_SELECTED)
  103.           {
  104.             int x, y;
  105.             LPSTR lpBuf;
  106.  
  107.             SortRect((LPRECT) &rMarked);
  108.  
  109.             if (ScrapInfo.hPasteBuffer == NULL)
  110.               ScrapInfo.hPasteBuffer = 
  111.                          GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 32L*32L);
  112.             lpBuf = GlobalLock(ScrapInfo.hPasteBuffer);
  113.  
  114.             for (x = rMarked.left;  x <= rMarked.right;  x += 8)
  115.               for (y = rMarked.top;  y <= rMarked.bottom;  y += 8)
  116.                 *lpBuf++ = (BYTE) GetIconPixel(x/8, y/8);
  117.             ScrapInfo.iWidth = (rMarked.right - rMarked.left) / 8 + 1;
  118.             ScrapInfo.iHeight = (rMarked.bottom - rMarked.top) / 8 + 1;
  119.  
  120.             ClearSelection(hWndEdit, &rMarked, iCurrentTool);
  121.             IconInfo.fFlags &= ~STATE_SOMETHING_SELECTED;
  122.             EnableMenuItem(GetMenu(hWndMain), IDM_PASTE, MF_BYCOMMAND | MF_ENABLED);
  123.             EnableMenuItem(GetMenu(hWndMain), IDM_COPY, MF_BYCOMMAND | MF_DISABLED);
  124.           }
  125.           break;
  126.  
  127.         case IDM_PASTE :
  128.           if (ScrapInfo.hPasteBuffer != NULL &&
  129.                 (IconInfo.fFlags & STATE_SOMETHING_SELECTED))
  130.           {
  131.             LPSTR lpBuf = GlobalLock(ScrapInfo.hPasteBuffer);
  132.             int   x, y;
  133.  
  134.             for (x = rMarked.left;  x <= rMarked.right;  x += 8)
  135.               for (y = rMarked.top;  y <= rMarked.bottom;  y += 8)
  136.                 SetIconPixel(x/8, y/8, *lpBuf++);
  137.  
  138.             GlobalUnlock(ScrapInfo.hPasteBuffer);
  139.             ClearSelection(hWndEdit, &rMarked, iCurrentTool);
  140.             IconInfo.fFlags &= ~STATE_SOMETHING_SELECTED;
  141.  
  142.             InvalidateAllWindows();
  143.           }
  144.           break;
  145.  
  146.         case IDM_UNDO :
  147.           IconUndo();
  148.           break;
  149.  
  150.  
  151.         case ID_COLOR0  :  case ID_COLOR1 :  case ID_COLOR2 :  case ID_COLOR3 :
  152.         case ID_COLOR4  :  case ID_COLOR5 :  case ID_COLOR6 :  case ID_COLOR7 :
  153.         case ID_COLOR8  :  case ID_COLOR9 :  case ID_COLOR10 : case ID_COLOR11 :
  154.         case ID_COLOR12 : case ID_COLOR13 : case ID_COLOR14 : case ID_COLOR15 :
  155.           CurrentColor = wParam - ID_COLOR0;
  156.           break;
  157.  
  158.         case ID_PENCIL   :
  159.         case ID_LINE     :
  160.         case ID_OPENRECT :
  161.         case ID_FILLRECT :
  162.         case ID_CIRCLE   :
  163.         case ID_FILLCIRC :
  164.         case ID_FLOOD    :
  165.         case ID_SELECT   :
  166.           iCurrentTool = wParam;
  167.           break;
  168.  
  169.       } /* end WM_COMMAND */
  170.       break;
  171.  
  172.  
  173.     case WM_CLOSE:
  174.       if (IconPromptForSave(hWnd) == TRUE)
  175.         DestroyWindow(hWnd);
  176.       break;
  177.  
  178.     case WM_QUERYENDSESSION:
  179.       return IconPromptForSave(hWnd);
  180.  
  181.     case WM_DESTROY:
  182.       PostQuitMessage(0);
  183.       break;
  184.  
  185.     default:
  186.       return DefWindowProc(hWnd, message, wParam, lParam);
  187.   }
  188.   return NULL;
  189. }
  190.  
  191.  
  192. /****************************************************************************/
  193. /*                                                                          */
  194. /* Function : ICOEditWndProc()                                              */
  195. /*                                                                          */
  196. /* Purpose  : Window proc for the icon editing window                       */
  197. /*                                                                          */
  198. /* Returns  :                                                               */
  199. /*                                                                          */
  200. /****************************************************************************/
  201. long FAR PASCAL ICOEditWndProc(hWnd, message, wParam, lParam)
  202.   HWND hWnd;
  203.   unsigned message;
  204.   WORD wParam;
  205.   LONG lParam;
  206. {
  207.   static BOOL bMarking = FALSE;
  208.   static POINT ptLast;
  209.   POINT  pt;
  210.   char   szMsg[80];
  211.  
  212.  
  213.   switch (message)
  214.   {
  215.     case WM_SETCURSOR :
  216.       /*
  217.         Set the mouse cursor to certain shape, depending on the tool
  218.       */
  219.       switch (iCurrentTool)
  220.       {
  221.         case ID_PENCIL   :
  222.           SetCursor(LoadCursor(NULL, IDC_ARROW));
  223.           break;
  224.         case ID_LINE     :
  225.           SetCursor(LoadCursor(NULL, IDC_CROSS));
  226.           break;
  227.         case ID_OPENRECT :
  228.           SetCursor(LoadCursor(NULL, IDC_CROSS));
  229.           break;
  230.         case ID_FILLRECT :
  231.           SetCursor(LoadCursor(NULL, IDC_CROSS));
  232.           break;
  233.         case ID_CIRCLE   :
  234.           SetCursor(LoadCursor(NULL, IDC_CROSS));
  235.           break;
  236.         case ID_FILLCIRC :
  237.           SetCursor(LoadCursor(NULL, IDC_CROSS));
  238.           break;
  239.         default :
  240.           SetCursor(LoadCursor(NULL, IDC_ARROW));
  241.           break;
  242.       }
  243.       return TRUE;
  244.  
  245.  
  246.     case WM_LBUTTONDOWN:
  247.       if (IconInfo.fFlags & STATE_SOMETHING_SELECTED)
  248.       {
  249.         ClearSelection(hWnd, &rMarked, ID_SELECT);
  250.         IconInfo.fFlags &= ~STATE_SOMETHING_SELECTED;
  251.       }
  252.  
  253.       bMarking = TRUE;     /* user has pressed the left button */
  254.       IconCheckpoint();
  255.  
  256.       if (iCurrentTool == ID_PENCIL)
  257.       {
  258.         HBRUSH hBrush, hOldBrush;
  259.         HDC    hDC;
  260.         RECT   rPixel;
  261.         extern BYTE rgb[16][3];
  262.  
  263.         pt = MAKEPOINT(lParam);
  264.         SetIconPixel(ptLast.x = (pt.x/8), ptLast.y = (pt.y/8), CurrentColor);
  265.  
  266.         hDC = GetDC(hWndEdit);
  267.         hBrush = CreateSolidBrush(RGB(rgb[CurrentColor][2], rgb[CurrentColor][1], rgb[CurrentColor][0]));
  268.         hOldBrush = SelectObject(hDC, hBrush);
  269.  
  270.         pt.x = (pt.x * 8) / 8;
  271.         pt.y = (pt.y * 8) / 8;
  272.         pt.x = ptLast.x * 8;
  273.         pt.y = ptLast.y * 8;
  274.         SetRect((LPRECT) &rPixel, pt.x, pt.y, pt.x+8, pt.y+8);
  275.         FillRect(hDC, (LPRECT) &rPixel, hBrush);
  276.  
  277.         SelectObject(hDC, hOldBrush);
  278.         DeleteObject(hBrush);
  279.         ReleaseDC(hWndEdit, hDC);
  280.         InvalidateRect(hWndActualImage, (LPRECT) NULL, FALSE);
  281.         if (hWndDebug)
  282.         {
  283.           InvalidateRect(hWndDebug, (LPRECT) NULL, FALSE);
  284.           UpdateWindow(hWndDebug);
  285.         }
  286.       }
  287.       else
  288.       {
  289.         SetRectEmpty(&rMarked);
  290.         StartSelection(hWnd, MAKEPOINT(lParam), &rMarked, iCurrentTool);
  291.       }
  292.       IconInfo.fFlags |= STATE_DIRTY;
  293.       break;
  294.  
  295.  
  296.     case WM_MOUSEMOVE:
  297.       if (bMarking)
  298.       {
  299.         if (iCurrentTool == ID_PENCIL)
  300.         {
  301.           HBRUSH hBrush, hOldBrush;
  302.           HDC    hDC;
  303.           RECT   rPixel;
  304.           extern BYTE rgb[16][3];
  305.  
  306.           pt = MAKEPOINT(lParam);
  307.           if (ptLast.x == pt.x / 8  &&  ptLast.y == pt.y / 8)
  308.             break;
  309.           SetIconPixel(ptLast.x = (pt.x/8), ptLast.y = (pt.y/8), CurrentColor);
  310.  
  311.           hDC = GetDC(hWndEdit);
  312.           hBrush = CreateSolidBrush(RGB(rgb[CurrentColor][2], rgb[CurrentColor][1], rgb[CurrentColor][0]));
  313.           hOldBrush = SelectObject(hDC, hBrush);
  314.  
  315.           pt.x = pt.x * 8 / 8;
  316.           pt.y = pt.y * 8 / 8;
  317.           pt.x = ptLast.x * 8;
  318.           pt.y = ptLast.y * 8;
  319.           SetRect((LPRECT) &rPixel, pt.x, pt.y, pt.x+8, pt.y+8);
  320.           FillRect(hDC, (LPRECT) &rPixel, hBrush);
  321.  
  322.           SelectObject(hDC, hOldBrush);
  323.           DeleteObject(hBrush);
  324.           ReleaseDC(hWndEdit, hDC);
  325.  
  326.           InvalidateRect(hWndActualImage, (LPRECT) NULL, FALSE);
  327.           if (hWndDebug)
  328.           {
  329.             InvalidateRect(hWndDebug, (LPRECT) NULL, FALSE);
  330.             UpdateWindow(hWndDebug);
  331.           }
  332.         }
  333.         else
  334.           UpdateSelection(hWnd, MAKEPOINT(lParam), &rMarked, iCurrentTool);
  335.       }
  336.       break;
  337.  
  338.  
  339.     case WM_LBUTTONUP:
  340.       if (bMarking) 
  341.       {
  342.         bMarking = FALSE;
  343.         EndSelection(MAKEPOINT(lParam), &rMarked);
  344.         if (iCurrentTool != ID_SELECT)
  345.           ClearSelection(hWnd, &rMarked, iCurrentTool);
  346.  
  347.         switch (iCurrentTool)
  348.         {
  349.           case ID_FILLRECT :
  350.           {
  351.             int x, y;
  352.             SortRect((LPRECT) &rMarked);
  353.             for (x = rMarked.left;  x <= rMarked.right;  x += 8)
  354.               for (y = rMarked.top;  y <= rMarked.bottom;  y += 8)
  355.                 SetIconPixel(x/8, y/8, CurrentColor);
  356.             break;
  357.           }
  358.  
  359.           case ID_OPENRECT :
  360.           {
  361.             int x, y;
  362.             SortRect((LPRECT) &rMarked);
  363.             for (x = rMarked.left;  x <= rMarked.right;  x += 8)
  364.               SetIconPixel(x/8, rMarked.top/8, CurrentColor);
  365.             for (x = rMarked.left;  x <= rMarked.right;  x += 8)
  366.               SetIconPixel(x/8, rMarked.bottom/8, CurrentColor);
  367.             for (y = rMarked.top;  y <= rMarked.bottom;  y += 8)
  368.               SetIconPixel(rMarked.left/8, y/8, CurrentColor);
  369.             for (y = rMarked.top;  y <= rMarked.bottom;  y += 8)
  370.               SetIconPixel(rMarked.right/8, y/8, CurrentColor);
  371.             break;
  372.           }
  373.  
  374.  
  375.           case ID_LINE     :
  376.           {
  377.             FARPROC lpProc;
  378.  
  379.             lpProc = MakeProcInstance(IconPlotLine, hInst);
  380.             LineDDA(rMarked.left, rMarked.top, rMarked.right, rMarked.bottom,
  381.                     lpProc, (LPSTR) MAKELONG(CurrentColor, 0));
  382.             FreeProcInstance(lpProc);
  383.             break;
  384.           }
  385.  
  386.           case ID_CIRCLE   :
  387.           case ID_FILLCIRC :
  388.           {
  389.             HDC hDC = GetDC(hWndActualImage);
  390.  
  391.             SortRect((LPRECT) &rMarked);
  392.             DrawCircleInBitmap(hWndActualImage, hDC, IconInfo.hBitmapBits,
  393.                 rMarked.left/8, rMarked.top/8, rMarked.right/8, rMarked.bottom/8);
  394.  
  395.             ReleaseDC(hWndActualImage, hDC);
  396.             break;
  397.           }
  398.  
  399.           case ID_FLOOD :
  400.           {
  401.             HDC hDC = GetDC(hWndActualImage);
  402.  
  403.             pt = MAKEPOINT(lParam);
  404.             FloodFillBitmap(hWndActualImage, hDC, IconInfo.hBitmapBits,
  405.                             rMarked.right/8, rMarked.bottom/8);
  406.             ReleaseDC(hWndActualImage, hDC);
  407.           }
  408.         }
  409.  
  410.         if (iCurrentTool == ID_SELECT)
  411.         {
  412.           SortRect((LPRECT) &rMarked);
  413.           IconInfo.fFlags |= STATE_SOMETHING_SELECTED;
  414.           EnableMenuItem(GetMenu(hWndMain), IDM_COPY, MF_BYCOMMAND | MF_ENABLED);
  415.           if (ScrapInfo.hPasteBuffer != NULL)
  416.             EnableMenuItem(GetMenu(hWndMain), IDM_PASTE, MF_BYCOMMAND | MF_ENABLED);
  417.         }
  418.         else if (iCurrentTool != ID_PENCIL)
  419.         {
  420.           InvalidateAllWindows();
  421.         }
  422.       }
  423.       break;
  424.  
  425.  
  426.     case WM_PAINT :
  427.       if (IconInfo.hBitmapBits != NULL)
  428.       {
  429.         HDC hDC;
  430.         PAINTSTRUCT ps;
  431.  
  432.         hDC = BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);
  433.         DisplayDIBitmap(hWnd, hDC, IconInfo.hBitmapBits);
  434.         EndPaint(hWnd, (LPPAINTSTRUCT) &ps);
  435.         break;
  436.       }
  437.       /* else fall through ...*/
  438.  
  439.     default:
  440.       return DefWindowProc(hWnd, message, wParam, lParam);
  441.   }
  442.   return NULL;
  443. }
  444.  
  445.  
  446. /****************************************************************************/
  447. /*                                                                          */
  448. /* Function : ICOImageWndProc()                                             */
  449. /*                                                                          */
  450. /* Purpose  : Winproc for the actual icon image window. All this does is    */
  451. /*            call the bitmap display procedure in response to WM_PAINTs.   */
  452. /*                                                                          */
  453. /* Returns  :                                                               */
  454. /*                                                                          */
  455. /****************************************************************************/
  456. long FAR PASCAL ICOImageWndProc(hWnd, message, wParam, lParam)
  457.   HWND hWnd;
  458.   unsigned message;
  459.   WORD wParam;
  460.   LONG lParam;
  461. {
  462.   switch (message)
  463.   {
  464.     case WM_PAINT :
  465.       if (IconInfo.hBitmapBits != NULL)
  466.       {
  467.         HDC hDC;
  468.         PAINTSTRUCT ps;
  469.  
  470.         hDC = BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);
  471.         DisplayDIBitmap(hWnd, hDC, IconInfo.hBitmapBits);
  472.         EndPaint(hWnd, (LPPAINTSTRUCT) &ps);
  473.         break;
  474.       }
  475.       /* else fall through ...*/
  476.  
  477.     default:
  478.       return DefWindowProc(hWnd, message, wParam, lParam);
  479.   }
  480.   return NULL;
  481. }
  482.  
  483.  
  484. /****************************************************************************/
  485. /*                                                                          */
  486. /* Function : IconPromptForSave()                                           */
  487. /*                                                                          */
  488. /* Purpose  : Prompts the user to save the current pixmap                   */
  489. /*                                                                          */
  490. /* Returns  : TRUE if the app should terminate (or start a new icon).       */
  491. /*                                                                          */
  492. /****************************************************************************/
  493. BOOL PASCAL IconPromptForSave(HWND hWnd)
  494. {
  495.   if (IconInfo.fFlags & STATE_DIRTY)
  496.   {
  497.     int rc = MessageBox(hWnd, "Save changes?", "Warning", MB_YESNOCANCEL);
  498.     if (rc == IDYES)
  499.     {
  500.       SendMessage(hWnd, WM_COMMAND, IDM_SAVE, 0L);
  501.       IconInfo.fFlags &= ~ STATE_DIRTY;
  502.       return TRUE;
  503.     }
  504.     else if (rc == IDCANCEL)
  505.       return FALSE;
  506.     else if (rc == IDNO)
  507.       return TRUE;
  508.   }
  509.   else
  510.     return TRUE;
  511. }
  512.  
  513.  
  514. /****************************************************************************/
  515. /*                                                                          */
  516. /*          ROUTINES TO IMPLEMENT UNDO IN THE ICON EDITOR                   */
  517. /*                                                                          */
  518. /****************************************************************************/
  519.  
  520. typedef struct tagUndoInfo
  521. {
  522.   HANDLE hUndoBitmap;
  523. } UNDOINFO;
  524.  
  525. UNDOINFO UndoInfo = 
  526. {
  527.   NULL
  528. };
  529.  
  530.  
  531. /****************************************************************************/
  532. /*                                                                          */
  533. /* Function : IconUndo()                                                    */
  534. /*                                                                          */
  535. /* Purpose  : Restores the undo info.                                       */
  536. /*                                                                          */
  537. /* Returns  : Nicht.                                                        */
  538. /*                                                                          */
  539. /****************************************************************************/
  540. VOID PASCAL IconUndo(void)
  541. {
  542.   if (UndoInfo.hUndoBitmap != NULL)
  543.   {
  544.     /*
  545.       Make the shadow buffer the current pixmap
  546.     */
  547.     GlobalFree(IconInfo.hBitmapBits);
  548.     IconInfo.hBitmapBits = UndoInfo.hUndoBitmap;
  549.     UndoInfo.hUndoBitmap = NULL;
  550.  
  551.     InvalidateAllWindows();
  552.     /*
  553.       No more undo info, so disable the UNDO menu selection
  554.     */
  555.     EnableMenuItem(GetMenu(hWndMain), IDM_UNDO, 
  556.                    MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
  557.   }
  558. }
  559.  
  560.  
  561. /****************************************************************************/
  562. /*                                                                          */
  563. /* Function : IconCheckpoint()                                              */
  564. /*                                                                          */
  565. /* Purpose  : Saves a copy of the current pixmap for undo purposes.         */
  566. /*                                                                          */
  567. /* Returns  : Squat.                                                        */
  568. /*                                                                          */
  569. /****************************************************************************/
  570. VOID PASCAL IconCheckpoint(void)
  571. {
  572.   LPSTR lpUndo, lpBits;
  573.   int   nPixelsPerByte = 2;
  574.  
  575.   /*
  576.     Allocate a shadow pixmap to hold the undo info in
  577.   */
  578.   if (UndoInfo.hUndoBitmap == NULL)
  579.   {
  580.     if ((UndoInfo.hUndoBitmap = 
  581.            GlobalAlloc(GMEM_MOVEABLE | GMEM_ZEROINIT, 32L*32L)) == NULL)
  582.       return;
  583.   }
  584.  
  585.   lpUndo = GlobalLock(UndoInfo.hUndoBitmap);
  586.   lpBits = GlobalLock(IconInfo.hBitmapBits);
  587.  
  588.   /*
  589.     Save a copy of the current pixmap in the shadow buffer
  590.   */
  591.   _fmemcpy(lpUndo, lpBits, IconDir.Width / nPixelsPerByte * IconDir.Height);
  592.  
  593.   GlobalUnlock(UndoInfo.hUndoBitmap);
  594.   GlobalUnlock(IconInfo.hBitmapBits);
  595.  
  596.   /*
  597.     We now have undo info saved, so enable the UNDO menu selection
  598.   */
  599.   EnableMenuItem(GetMenu(hWndMain), IDM_UNDO, MF_BYCOMMAND | MF_ENABLED);
  600. }
  601.  
  602.  
  603. /****************************************************************************/
  604. /*                                                                          */
  605. /* Function : ICODebugWndProc()                                             */
  606. /*                                                                          */
  607. /* Purpose  : Winproc for the debugging window.                             */
  608. /*                                                                          */
  609. /* Returns  :                                                               */
  610. /*                                                                          */
  611. /****************************************************************************/
  612. long FAR PASCAL ICODebugWndProc(hWnd, message, wParam, lParam)
  613.   HWND hWnd;
  614.   unsigned message;
  615.   WORD wParam;
  616.   LONG lParam;
  617. {
  618.   switch (message)
  619.   {
  620.     case WM_DESTROY :
  621.       hWndDebug = NULL;
  622.       break;
  623.  
  624.     case WM_PAINT :
  625.       if (IconInfo.hBitmapBits != NULL)
  626.       {
  627.         PAINTSTRUCT ps;
  628.  
  629.         BeginPaint(hWnd, (LPPAINTSTRUCT) &ps);
  630.         EndPaint(hWnd, (LPPAINTSTRUCT) &ps);
  631. #ifdef DEBUG
  632.         DebugBitmap(hWnd, IconInfo.hBitmapBits);
  633. #endif
  634.         break;
  635.       }
  636.       /* else fall through ...*/
  637.  
  638.     default:
  639.       return DefWindowProc(hWnd, message, wParam, lParam);
  640.   }
  641.   return NULL;
  642. }
  643.  
  644.  
  645. VOID PASCAL InvalidateAllWindows(void)
  646. {
  647.   InvalidateRect(hWndEdit, (LPRECT) NULL, FALSE);
  648.   UpdateWindow(hWndEdit);
  649.   InvalidateRect(hWndActualImage, (LPRECT) NULL, FALSE);
  650.   UpdateWindow(hWndActualImage);
  651.   if (hWndDebug)
  652.   {
  653.     InvalidateRect(hWndDebug, (LPRECT) NULL, FALSE);
  654.     UpdateWindow(hWndDebug);
  655.   }
  656. }
  657.